package com.demo.springcloud.controller;

import com.demo.springcloud.pojo.CommonResult;
import com.demo.springcloud.service.AccountService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.math.BigDecimal;

/**
 * @author chenyuan
 * @date 2020/12/24 15:39
 */
@RestController
@Slf4j
public class AccountController {
	@Resource
	AccountService accountService;

	/**
	 * 扣减账户余额
	 */
	@RequestMapping("/account/decrease")
	public CommonResult decrease(@RequestParam("userId") Long userId, @RequestParam("money") BigDecimal money) {
		int decrease = accountService.decrease(userId, money);
		log.info("------ account-decrease-影响行数 ：" + decrease);
		return new CommonResult(200, "扣减账户余额成功！", decrease);
	}
}
